<%@ page language="java" import="com.qipay.admin.utils.SiteHelper" contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page import="com.qipay.admin.spronghuimch.vo.SpRonghuiChannelDTO" %>
<%@ page import="com.qipay.baas.model.SpRonghuiMch" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/dataTables.bootstrap.min.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <% SpRonghuiMch spRonghuiMch = (SpRonghuiMch) request.getAttribute("detail");%>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <% if (request.getParameter("error")!=null){%>
                        <div class="alert alert-error">
                            添加支付类型失败。
                        </div>
                        <%}%>
                        <div class="box-header">
                            <h3 class="box-title"><%= spRonghuiMch != null ? spRonghuiMch.getMerchantName() : "SpRonghuiMch"%>支付列表</h3>
                        </div>
                        <div class="col-xs-10">
                            <form class="form-inline">
                                <a class="btn btn-success"
              href="${pageContext.request.contextPath}/sp/ronghuimch/paytype/add?spRonghuiMchId=<%= spRonghuiMch != null ? spRonghuiMch.getId() : null%>&&
merchantNo=<%= spRonghuiMch != null ? spRonghuiMch.getMerchantNo() : null%>">添加渠道</a>
                                <a class="btn btn-info"
                                   href="javascript:window.history.back()">返回</a>
                            </form>
                        </div>
                        <br>
                        <hr>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>入网商户名称</th>
                                    <th>支付方式</th>
                                    <th>t1手续费</th>
                                    <th>t0手续费</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <% List<SpRonghuiChannelDTO> articles = (List<SpRonghuiChannelDTO>) request.getAttribute("lst");
                                    if (articles != null && articles.size() > 0) {
                                        Iterator<SpRonghuiChannelDTO> iter = articles.iterator();
                                        SpRonghuiChannelDTO user = null;
                                        while (iter.hasNext()) {
                                            user = iter.next();
                                %>
                                <tr id="user_<%=user.getId()%>">
                                    <td><%=user.getId()%></td>
                                    <td><%= spRonghuiMch.getMerchantName()%></td>
                                    <td><%=SiteHelper.getProductType(user.getProductType())%></td>
                                    <td><%=user.getT1fee()%></td>
                                    <td><%=user.getT0fee()%></td>
                                  <%--  <td>
                                        <a name="linkNetProtype"
                                           pk="<%= user.getId()%>" class="btn btn-danger btn-xs">开通</a>
                                        <a class="btn btn-info btn-xs"
                                           href="${pageContext.request.contextPath}/cpnet/paytype/<%= user.getId()%>?merchantNo=<%=user.getMerchantNo()%>">修改</a>
                                    </td>--%>
                                </tr>

                                <%
                                    }
                                } else {
                                %>
                                <tr>
                                    <td colspan="7">no data.</td>
                                </tr>
                                <% }%>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <jsp:include page="foot.jsp"></jsp:include>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.dataTables.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/dataTables.bootstrap.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.slimscroll.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/fastclick.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>
<script>
    $(function () {
        $('#example2').DataTable({
            'paging': true,
            'lengthChange': false,
            'searching': false,
            'ordering': true,
            'info': true,
            'autoWidth': false
        });
        $("[name='linkNetProtype']").click(function () {
            var pk = $(this).attr("pk");
            if (pk > 0) {
                if (confirm("申请开通？")) {
                    $.ajax({
                        url: "/sp/ronghuimch/paytype/" + pk + "/apply",
                        type: "POST",
                        async: true,//true异步 false同步
                        context: this,
                        dataType: "json",
                        success: function (data) {
                            console.log(data);
                            if (data != null && data.code == "1") {
                                $("#user_" + pk).hide(100);
                                alert("开通支付成功:");
                            }
                            else {
                                alert("fail:" + data.msg);
                            }
                        },
                        error: function (d, s, b) {
                            alert("失败:" + b);
                        }
                    });
                }
            }

        });
    })
</script>
</body>
</html>

